package com.wondersgroup.app.appointment.controller;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wondersgroup.core.frame.BaseController;
import com.wondersgroup.core.frame.CommonStatusResult;
import com.wondersgroup.core.model.Company;
import com.wondersgroup.core.resultmap.DTOCompany;
import com.wondersgroup.core.service.CompanyService;
import com.wondersgroup.core.util.ErrorMessageConstant;

@Controller
@RequestMapping("/company")
public class CompanyController extends BaseController{

	@Resource
	private CompanyService companyService;

	@RequestMapping(value="/query" ,method = RequestMethod.POST)
	@ResponseBody
	public CommonStatusResult queryCompany(@RequestParam(required=false,value="name") String companyMsg,
			@RequestParam(required=false,value="latitude") String latitude,
			@RequestParam(required=false,value="longitude") String longitude){
		Map<String, Object> parameterMap = new HashMap<String, Object>();
		if(companyMsg!=null&&!companyMsg.equals("")){
			parameterMap.put("companyMsg", companyMsg);
		}
		if(latitude!=null&&!latitude.equals("")&&longitude!=null&&!longitude.equals("")){
			parameterMap.put("latitude", latitude);
	   	 	parameterMap.put("longitude",longitude);
		}
   	 
		List<DTOCompany> list =  companyService.queryCompany(parameterMap);

		if(list.size()==0||list==null){
			return CommonStatusResult.fail(ErrorMessageConstant.CODE_FAIL, null);
			
		}else{
			return CommonStatusResult.success(ErrorMessageConstant.CODE_SUCCESS, list);
			
		}
	}
	
	
	
	@RequestMapping(value="/test" ,method = RequestMethod.GET)
	@ResponseBody
	public CommonStatusResult queryCompany(){
		return CommonStatusResult.success(ErrorMessageConstant.CODE_SUCCESS, 919);
	}
	
}
